
package org.flowable.ui.common.security;

import java.util.ArrayList;

import org.flowable.idm.api.User;
import org.flowable.ui.common.model.RemoteUser;

/**
 * Utility class for Spring Security.
 */
public class SecurityUtils {

    private static User assumeUser;

    private SecurityUtils() {
    }

    /**
     * Get the login of the current user.
     */
    public static String getCurrentUserId() {
        return null;
    }

    /**
     * @return the {@link User} object associated with the current logged in user.
     */
	public static User getCurrentUserObject() {
        if (assumeUser != null) {
            return assumeUser;
        }

        User user = new RemoteUser();
        user.setId("001");
        user.setDisplayName("001");
        user.setPassword("001");
        user.setTenantId("001");
        return user;
    }

    public static FlowableAppUser getCurrentFlowableAppUser() {
    	User s = getCurrentUserObject();
        FlowableAppUser user = new FlowableAppUser(s, s.getId(), new ArrayList<>());
        return user;
    }

    public static boolean currentUserHasCapability(String capability) {
    	return true;
    }

    public static void assumeUser(User user) {
        assumeUser = user;
    }

    public static void clearAssumeUser() {
        assumeUser = null;
    }

}
